|
In combinatorial mathematics, probability, and computer science, in the longest alternating subsequence problem, one wants to find a subsequence of a given sequence in which the elements are in alternating order, and in which the sequence is as long as possible. Formally, if is a sequence of distinct real numbers, then the subsequence is ''alternating''〔name="Stanleybook">〕 (or ''zigzag'' or ''down-up'')if : Similarly, is ''reverse alternating'' (or ''up-down'') if : Let denote the length (number of terms) of the longest alternating subsequence of . For example, if we consider some of the permutations of the integers 1,2,3,4,5, we have that * ; because any sequence of 2 distinct digits are (by definition) alternating. (for example 1,2 or 1,4 or 3,5) * because 1,5,3,4 and 1,5,2,4 and 1,3,2,4 are all alternating, and there is no alternating subsequence with more elements; * because 5,3,4,1,2 is itself alternating. == Efficient algorithms == The longest alternating subsequence problem is solvable in time , where is the length of the original sequence. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Longest alternating subsequence」の詳細全文を読む スポンサード リンク
|